GSList *items;
gchar *action_namespace;
+ guint separator_label : 1;
guint with_separators : 1;
guint has_separator : 1;
static GtkMenuTrackerSection * gtk_menu_tracker_section_new (GtkMenuTracker *tracker,
GMenuModel *model,
gboolean with_separators,
+ gboolean separator_label,
gint offset,
const gchar *action_namespace);
static void gtk_menu_tracker_section_free (GtkMenuTrackerSection *section);
{
gboolean could_have_separator;
- could_have_separator = (section->with_separators && n_items > 0) ||
- g_menu_model_get_item_attribute (section->model, i, "label", "s", NULL);
+ could_have_separator = (section->with_separators && n_items > 0) || subsection->separator_label;
+ /* Only pass the parent_model and parent_index in case they may be used to create the separator. */
n_items += gtk_menu_tracker_section_sync_separators (subsection, tracker, offset + n_items,
- could_have_separator, section->model, i);
+ could_have_separator,
+ could_have_separator ? section->model : NULL,
+ could_have_separator ? i : 0);
}
else
n_items++;
{
GtkMenuTrackerSection *subsection;
gchar *action_namespace = NULL;
+ gboolean has_label;
+
+ has_label = g_menu_model_get_item_attribute (model, position + n_items,
+ G_MENU_ATTRIBUTE_LABEL, "s", NULL);
g_menu_model_get_item_attribute (model, position + n_items,
G_MENU_ATTRIBUTE_ACTION_NAMESPACE, "s", &action_namespace);
gchar *namespace;
namespace = g_strjoin (".", section->action_namespace, action_namespace, NULL);
- subsection = gtk_menu_tracker_section_new (tracker, submenu, FALSE, offset, namespace);
+ subsection = gtk_menu_tracker_section_new (tracker, submenu, FALSE, has_label, offset, namespace);
g_free (namespace);
}
else
- subsection = gtk_menu_tracker_section_new (tracker, submenu, FALSE, offset, action_namespace);
+ subsection = gtk_menu_tracker_section_new (tracker, submenu, FALSE, has_label, offset, action_namespace);
*change_point = g_slist_prepend (*change_point, subsection);
g_free (action_namespace);
gtk_menu_tracker_section_new (GtkMenuTracker *tracker,
GMenuModel *model,
gboolean with_separators,
+ gboolean separator_label,
gint offset,
const gchar *action_namespace)
{
section->model = g_object_ref (model);
section->with_separators = with_separators;
section->action_namespace = g_strdup (action_namespace);
+ section->separator_label = separator_label;
gtk_menu_tracker_add_items (tracker, section, §ion->items, offset, model, 0, g_menu_model_get_n_items (model));
section->handler = g_signal_connect (model, "items-changed", G_CALLBACK (gtk_menu_tracker_model_changed), tracker);
tracker->remove_func = remove_func;
tracker->user_data = user_data;
- tracker->toplevel = gtk_menu_tracker_section_new (tracker, model, with_separators, 0, action_namespace);
+ tracker->toplevel = gtk_menu_tracker_section_new (tracker, model, with_separators, FALSE, 0, action_namespace);
gtk_menu_tracker_section_sync_separators (tracker->toplevel, tracker, 0, FALSE, NULL, 0);
return tracker;